package com.wxg.study.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.wxg.study.bean.MyBean;
import com.wxg.study.conf.Config;
import com.wxg.study.conf.FooProperties;
import com.wxg.study.service.HelloService;

@Service("helloService")
public class HelloServiceImpl implements HelloService {

	final Logger logger = LoggerFactory.getLogger(HelloServiceImpl.class);
	
	@Autowired
	private MyBean myBean;
	
	@Autowired
	private Config config;
	
	@Autowired
	private FooProperties fooProp;
	
	@Override
	public String hello(String name) {
		
		// 使用 @Value("${name}") 获取的值
		logger.info("name : {}", myBean.getName());
		
		logger.info("secret : {}", myBean.getSecret());
		
		logger.info("number : {}", myBean.getNumber());
		
		logger.info("bignumber : {}", myBean.getBignumber());
		
		logger.info("app.name : {}", myBean.getAppName());
		
		logger.info("app.description : {}", myBean.getAppDescription());
		
		logger.info("my.servers : {}", config.getServers());
		
		logger.info("my pojo : {}", fooProp.getList());
		
		if (StringUtils.isEmpty(name)) {
			return "hello ...";
		} else {
			return "hello " + name;
		}
	}

}
